<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>董胜烨第三次作业</title>
    <link rel="stylesheet"
          href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/default.min.css">
    <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script>
    <script>hljs.highlightAll();</script>
</head>
<body>
<pre><code class="python">from functools import wraps

class AuthClass:
    def __init__(self, name, pwd):
        self.name = name
        self.pwd = pwd

    def auth(self):
        if self.name == "python" and self.pwd == "123":
            return True
        else:
            return False

user = AuthClass("python", "1123")

def auth_before(f):
    @wraps(f)
    def inner(*args, **kwargs):
        if not user.auth():
            print("用户名或密码错误")
            return False
        else:
            return f(*args, **kwargs)
    return inner

@auth_before
def p1():
    return "this is p1 function"

print(p1())</code></pre>


<script>

</script>
</body>
</html>